So, as promised in my previous blog entry, this is how I use the Twitter api with VB.Net to set my Twitter status and to get my Twitter Status.
The setTwitterStatus function accepts three parameters, the username, password and the status.
You can download the full source code near the end of this article.
The setTwitterStatus function accepts three parameters, the username, password and the status.
You can download the full source code near the end of this article.
'Using Webclient With Credentials To Set Twitter Status
Public Function setTwitterStatus(ByVal user As String, ByVal pass As String, ByVal status As String) As String
Dim url As String = "http://twitter.com/statuses/update.xml?status=" & status
Dim HTMLSource As String = ""
Dim WC As New WebClient
WC.Credentials = New NetworkCredential(user, pass)
HTMLSource = WC.UploadString(url, "")
Return parseTwitterXML(HTMLSource)
End Function
'Parse The Twitter Response XML
Public Function parseTwitterXML(ByVal XML As String) As String
Dim Str As String = ""
Dim XDoc As New XmlDocument
XDoc.LoadXml(XML)
Dim XNode As XmlNode
For Each XNode In XDoc.DocumentElement.SelectNodes("//status")
Str += XNode.Item("created_at").InnerText & ", " & XNode.Item("text").InnerText & vbNewLine & vbNewLine
Next
Return Str
End Function
« Leave Comment »

